﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 方法的递归
{
    class Program
    {
        static void Main(string[] args)
        {
            // 计算5！
            // f(n) = n * f(n-1)
            int a = M1(5);
            Console.WriteLine(a);
            Console.WriteLine(F(5));
        }

        public static int M1(int n)
        {
            if (n == 1)
            {
                return 1;
            }
            return n * (M1(n - 1));
        }

        // F(n) = F(n - 1) + F(n - 2)， F(0) = 2，F(1) = 3， 求F(5)
        public static int F(int n)
        {
            if (n == 0)
            {
                return 2;
            }
            if (n == 1)
            {
                return 3;
            }
            return F(n - 1) + F(n - 2);
        }
    }
}
